<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
            var arr=[1,2,3,4]
            var obj={name:123}
    if(window.localStorage){
        localStorage.setItem("name","value")
        localStorage.setItem("num",20)
        localStorage.setItem("bool",true)
        localStorage.setItem("arr",[1,2,3,4])
        localStorage.setItem("obj",{name:123})
        var strarr=JSON.stringify(arr)
        var strobj=JSON.stringify(obj)
        localStorage.setItem("arr",strarr)
        localStorage.setItem("obj",strobj)
        
        var arr1=JSON.parse(localStorage.getItem("arr"))
        console.log(arr1)
        var obj1=JSON.parse(localStorage.getItem("obj"))
        console.log(obj1)
    }
    </script>
</body>
</html>